package com.jiayang.business.infraredpage;

import com.jiayang.base.equipment.StaEquipmentMapper;
import com.jiayang.base.equipment.domain.entity.StaEquipment;
import com.jiayang.business.infraredpage.domain.dto.PointTemperatureDTO;
import com.jiayang.common.domain.ResponseDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @ Author     ：OuyangChenglong
 * @ Date       ：Created in 10:11 2021/9/8
 * @ Description：设备信息服务层
 * @ Modified By：
 * @Version: $
 */
@Service
public class InfraredService {

    @Autowired
    private StaEquipmentMapper equipmentDao;

    @Autowired
    private InfraredDao infraredDao;

    public ResponseDTO getThermalImaging(String id) {
        // 获取热成像url
        StaEquipment equipmentEntity = equipmentDao.selectById(id);
        String thermalImagingUrl = equipmentEntity.getThermalImagingUrl();
        return ResponseDTO.succData(thermalImagingUrl);
    }

    public ResponseDTO getPointTemperature(PointTemperatureDTO pointTemperatureDTO) {
        // 获取点位温度
        String xLocation = pointTemperatureDTO.getXLocation();
        String yLocation = pointTemperatureDTO.getYLocation();
        String sensorId = pointTemperatureDTO.getSensorId();
        PointTemperatureDTO temperatureDTO = infraredDao.getPointTemperature(sensorId,xLocation,yLocation);
        return ResponseDTO.succData(temperatureDTO);
    }

    public ResponseDTO getInfraredState(String id) {
        PointTemperatureDTO temperatureDTO = new PointTemperatureDTO();
        // 状态正常
        temperatureDTO.setState("1");
        // 根据设备id查状态
        String state = infraredDao.getInfraredState(id);
        return ResponseDTO.succData(state);
    }
}
